package Questions;

import Users.AnswerReport;

import java.util.List;
import java.util.ArrayList;
import static TestApp.CONSTANTS.HELP_VERBAL_QUESTION;

/**
 * @author Myhaylo Kotsyuruba
 * @version v.1.4   14.03.13
 */

public class VerbalQuestion extends QuestionWithoutChoice {
    private ArrayList<String> answers;

    public VerbalQuestion(String text, int score, List<String> parameters) {
        super(text, score, HELP_VERBAL_QUESTION);
        answers = new ArrayList<String>(parameters);
    }

    @Override
    public AnswerReport getAnswerReport(String answer) {
        int quantityCorrectUserAnswers = 0;
        for (String word : answers) {
            if(answer.contains(word)) {
                quantityCorrectUserAnswers++;
            }
        }
        int userScore = getMaxScore() * quantityCorrectUserAnswers / answers.size();
        return new AnswerReport(answer, userScore, getMaxScore());
    }
}
